
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

import '../model/drop_data_model.dart';
import '../res/colors.dart';

buildConditionListWidget(List<IDropDataModel> items,
    void itemOnTap(IDropDataModel data)) {
  return ListView.separated(
    shrinkWrap: true,
    scrollDirection: Axis.vertical,
    itemCount: items.length,
    // item 的个数
    separatorBuilder: (BuildContext context, int index) =>
        Divider(height: 1.0),
    // 添加分割线
    itemBuilder: (BuildContext context, int index) {
      IDropDataModel goodsSortCondition = items[index];
      return GestureDetector(
        onTap: () {
          for (var value in items) {
            value.iSelected = false;
          }
          goodsSortCondition.iSelected = true;

          itemOnTap(goodsSortCondition);
        },
        child: Container(
          height: 40,
          child: Row(
            children: <Widget>[
              SizedBox(
                width: 16,
              ),
              Expanded(
                child: Text(
                  goodsSortCondition.iName,
                  style: TextStyle(
                    fontSize: 16,
                    color: goodsSortCondition.iSelected
                        ? Colours.app_main
                        : Colors.black,
                  ),
                ),
              ),
              goodsSortCondition.iSelected
                  ? Icon(
                Icons.check,
                color: Colours.app_main,
                size: 16,
              )
                  : SizedBox(),
              SizedBox(
                width: 16,
              ),
            ],
          ),
        ),
      );
    },
  );
}